package com.lanqiao.proxy;

/**
 * 静态代理模式
 */
public class Test {
    /**
     * 客户
     *
     * @param args
     */
    public static void main(String[] args) {
        SaleHouse saleHouse = new Proxy(new HouseMaster());
        saleHouse.sale();
    }
}

    /**
     * 卖房子
     */
     interface SaleHouse{
         public void sale();
     }

    /**
     *
     * 真正有房子的人(相当于IOC容器中的dao)
     */
     class HouseMaster implements SaleHouse{
         public void sale(){
             System.out.println("我是房东，我在卖房子");
         }
     }

    /**
     * 中介代理对象
     */
     class Proxy implements SaleHouse{
         SaleHouse master;

        public Proxy(SaleHouse master) {
            this.master = master;
        }

        public void sale(){
             System.out.println("我必须收你房东的中介费");
             master.sale();
             System.out.println("我必须收你客人的中介费");
         }

}
